package Client;

import module.Message;
import module.User;
import java.io.IOException;

public class StudentSystem {

    public static void studentLogin(ClientInitClose client) throws IOException, ClassNotFoundException {

        while (true) {
            System.out.println("请输入学员账号：");
            String uerName = ClientScanner.getScanner().next();
            System.out.println("请输入学员密码：");
            String password = ClientScanner.getScanner().next();
            Message inform = new Message("studentcheck", new User(uerName, password));
            client.getOut().writeObject(inform);
            System.out.println("账号登陆中...");
            inform = (Message) client.getIn().readObject();
            if ("success".equals(inform.getCheckFlag())) {
                System.out.println("管理员登陆成功！");
                StudentMainPage smp = new StudentMainPage();
                smp.studentMainPage(client,uerName);
                break;
            } else {
                System.out.println("管理员登录失败！账户或密码错误，请重新输入：");
            }
        }

    }

}
